package com.frejoys.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.frejoys.common.aop.Authority;
import com.frejoys.common.aop.Authorization;
import com.frejoys.common.constant.CommonConstant;
import com.frejoys.common.dto.admin.StoreIdAndNameDto;
import com.frejoys.common.dto.app.StoreWalletLogPageDto;
import com.frejoys.common.dto.common.IdDto;
import com.frejoys.common.response.Result;
import com.frejoys.common.vo.admin.StoreWalletListVo;
import com.frejoys.common.vo.app.StoreWalletLogPageVo;
import com.frejoys.service.StoreWalletLogService;
import com.frejoys.service.StoreWalletService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "商家钱包管理", description = "后台商家钱包管理")
@RestController
@RequiredArgsConstructor
@RequestMapping(CommonConstant.routePrefixAdmin)
@Authorization(Authority.Private)
public class AdminStoreWalletController {

    private final StoreWalletLogService storeWalletLogService;

    private final StoreWalletService storeWalletService;

    @Operation(summary = "分页查询商家提现信息")
    @PostMapping("/store/walletLog/page")
    public Result<Page<StoreWalletLogPageVo>> walletLogPage(@RequestBody @Validated StoreWalletLogPageDto dto) {
        return Result.success(storeWalletLogService.walletLogPage(dto));
    }

    @Operation(summary = "分页查询商家钱包明细信息")
    @PostMapping("/store/walletLog/list")
    public Result<Page<StoreWalletLogPageVo>> walletLogList(@RequestBody @Validated StoreWalletLogPageDto dto) {
        return Result.success(storeWalletLogService.walletLogPage(dto));
    }

    @Operation(summary = "查询商家钱包")
    @PostMapping("/store/walletLog/walletList")
    public Result<IPage<StoreWalletListVo>> walletList(@RequestBody @Validated StoreIdAndNameDto dto) {
        return Result.success(storeWalletService.walletList(dto));
    }

    //后台审核商家提现
    @Operation(summary = "审核商家提现")
    @PostMapping("/store/walletLog/check")
    public Result checkStoreWalletLog(@RequestBody @Validated IdDto dto) {
        storeWalletLogService.checkStoreWalletLog(dto);
        return Result.success();
    }
}
